package main

import "fmt"

func main() {
	nums := []int{0, 0, 1, 1, 1, 2, 2, 3, 3, 4}
	v := removeDuplicates(nums)
	fmt.Println(v)
}

// 删除有序数组中的重复项
// https://leetcode.cn/problems/remove-duplicates-from-sorted-array
func removeDuplicates(nums []int) int {
	l := len(nums)
	pos := 0
	for i := 1; i < l; i++ {
		if nums[i] != nums[pos] {
			nums[pos+1] = nums[i]
			pos++
		}
	}
	return pos + 1
}
